/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Iterator;
import java.util.Iterator;

/**
 *
 * @author Jenny Patrick
 */
public class ConjuntoPersona implements Iterable<Persona> {
    public Persona[] conjuntoPersonas;
    
    public ConjuntoPersona(Persona[]p){
        conjuntoPersonas = p;
    }
    
    public Iterator<Persona> iterator(){
        Iterator it = new MiIteratorPersona();
        return it;
    }
    
    protected class MiIteratorPersona implements Iterator<Persona>{
        protected int posicionarray;
        
        public MiIteratorPersona(){
            posicionarray = 0;
        }
        
        public boolean hasNext(){
            boolean result;
            
            if(posicionarray < conjuntoPersonas.length){
                result = true;
            }
            else{
                result = false;
            }
            return result;
        }
        
        public Persona next(){
            posicionarray++;
            return conjuntoPersonas[posicionarray-1];
        }
        
        public void remove(){
            throw new UnsupportedOperationException("No siportado");
        }
    }
}
